package com.master.demo.example.command;

import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * Spring validation 校验注解类
 * 参考路径 https://hazw.yuque.com/zth0go/rofhae/zp0h81#DuN7Q
 *
 * @author: Yang
 * @date: 2022/1/7
 * @version: 1.0.0
 * Copyright Ⓒ 2021 恒翔 Computer Corporation Limited All rights reserved.
 */
@Data
public class ValidateCommand {

    @NotNull(message = "姓名不能为空")
    private String name;

    @NotNull(message = "年龄不能为null")
    @Range(min = 1, max = 10, message = "年龄不符合")
    @Min(value = 1, message = "太少")
    private Integer age;

    @NotEmpty(message = "身份信息不为空")
    @Size(min = 1, max = 5, message = "身份信息内容过多或过少")
    private List<String> credentials;

}
